<?php

namespace app\comic\controller;

use app\comic\model\ComicModel;

class Index
{
	//添加漫画
	public function addComic()
	{
		
		/*$data = [
			'item'	=>	'"[MTSP(Jin)]橘さん家ノ男性事情 まとめ版 (全彩無修)"',
			'create_time'	=>	time(),
			'update_time'	=>	time(),
		];
	
		$comicModel = new ComicModel();
		$comicModel->add($data);*/
		
		//获取插入id 创建文件夹
		$path = __UPLOAD__.'/comic/'.'1';
		/*$comic_dir = $path;
		
		if (!file_exists($comic_dir)){
            mkdir($comic_dir,0777,true);
        }*/
		$logo_url = 'http://cdn-ms.cheaper.work/media/photos/148838/00002.jpg';
		downPic($logo_url,$path);
	}
	
	//添加漫画
	public function addComicPic()
	{
		set_time_limit(0);
		
		$comicModel = new ComicModel();
		
		$max = 254;
		$path = __UPLOAD__.'/comic/'.'1';
		for($int=1;$int++;$int<=$max){
			$logo_url = 'http://cdn-ms.cheaper.work/media/photos/148838/'.($int+10000).'.jpg';

			$logo_name = downPic($logo_url,$path);
			$data = [
				'pid' => 1,
				'pic' => $logo_name,
				'create_time'	=>	time(),
				'update_time'	=>	time(),
				'sort' => $int,
			];
			var_dump($data);exit;
			$comicModel->addPic($data);
		}
		
	}

	public function menuList()
	{
		$where = [
			't1.id' => 1
		];
		
		$comicModel = new ComicModel();
		$comicModel->getlist($where);
	}

	
}